﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO;

namespace JWBSTAPP.CommonClass
{
    public class ImageToByte
    {
        public byte[] ToByte(string fileSrc)
        {
            ///uploadfiles/temp/2013-05-08/20130508174305781.jpg
            FileInfo file = new FileInfo(ToPath(fileSrc));
            FileStream fs = file.OpenRead();
            byte[] bytes=new byte[fs.Length];
            fs.Read(bytes,0,Convert.ToInt32(fs.Length));
            return bytes;
        }

        public string ToPath(string filePath)
        {
            string path = filePath.Replace('/','\\');
            path = HttpRuntime.AppDomainAppPath + path;
            path = path.Replace("\\\\","\\");
            return path;
        }
    }
}